package com.jk.youxuanmall.coupon.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jk.youxuanmall.common.pojo.PagedResponse;
import com.jk.youxuanmall.common.utils.PaginationUtil;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.jk.youxuanmall.coupon.dao.CouponDao;
import com.jk.youxuanmall.coupon.entity.CouponEntity;
import com.jk.youxuanmall.coupon.service.CouponService;


@Service("couponService")
public class CouponServiceImpl extends ServiceImpl<CouponDao, CouponEntity> implements CouponService {

    @Override
    public PagedResponse<CouponEntity> queryPage(CouponEntity couponEntity, Integer pageNum, Integer pageSize) {
        Page<CouponEntity> page = new Page<>(pageNum, pageSize);
        QueryWrapper<CouponEntity> queryWrapper = new QueryWrapper<>();

        Page<CouponEntity> selectPage = this.baseMapper.selectPage(page, queryWrapper);

        return PaginationUtil.getPaginationResponse(selectPage.getRecords(), pageNum, pageSize, selectPage.getTotal());
    }

}